home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000115_icon-group-sender _Mon Apr 14 17:25:04 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: from kingfisher.CS.Arizona.EDU by cheltenham.cs.arizona.edu; Mon, 14 Apr 1997 12:43:27 MST
Received: by kingfisher.CS.Arizona.EDU; (5.65v3.2/1.1.8.2/08Nov94-0446PM)
id AA03699; Mon, 14 Apr 1997 12:43:27 -0700
To: icon-group@cs.arizona.edu
Date: 14 Apr 1997 17:25:04 GMT
From: eddie@tattoo.ed.ac.uk (Eddie Corns)
Message-Id: <5itp9g$4l5@scotsman.ed.ac.uk>
Organization: Edinburgh University
Sender: icon-group-request@cs.arizona.edu
References: <Stuart.Robinson-1204971710220001@asianstmg-203.anu.edu.au>
Subject: Re: More on Records
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1561
Stuart.Robinson@anu.edu.au (Stuart Robinson) writes:
>Suppose you want to scan through each line of a text looking for a
>particular type of word. Roughly speaking, the first time you find it, it
>should go to one field of a record and the second time you find it, it
>should go to another field of the same record. (The word will appear at
>most two times in a line, possibly not at all.) How would you do it?
I wouldn't. I would just use a list, they're wonderful things.
>More concretely, if you have the following line
>{T.p istam eCel 3{O stuK 1{A
I would probably try decrytping it!
>and a record with four fields like the following
>record[index1, arg1, index2, arg2]
>how do you write code that would take the first word with "{" followed by
>"S", "A", or "O" and put it into arg1 and its accompanying number into
>index1 and then take the second word in the same line with "{" followed by
>"S", "A", or "O" and put it into arg2 and its accompanying number into
>index2, as below?
>record[3, {O, 1, {A]
Well, assuming a split function to return an array of items:
rec := []
x := split(line)
every i := 1 to *x do x[i] ?
if tab(find("{")+1) & =("A"|"S"|"O") then put(rec,i) & put(rec,x[i])
(Hmmm that's a bit clumsy, can I do =!"ASO" - can't be bothered typing it in
again to try it)
This creates a list of found items rather than a record. I'm not sure if put()
works on records, if not and you really want to use a record you'd just need a
counter to keep track (since you _can_ address elements of a record by
position).
Eddie